package com.baosight.risk.common.email.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import org.springframework.stereotype.Service;

/**
 * @desc: 邮件接口实现类
 * @author: CuiShiHao
 **/
@Service
public class EmailServiceImpl implements EmailService {

    /**
     * @param loginName  用户登录账号名称
     * @param subjet     邮件主题
     * @param message    邮件内容
     * @param attachFile 邮件附件，多个附件用;分割
     * @return 返还结果
     * @description 调用平台接口发送邮件到指定登录账户
     * @author CuiShiHao
     */
    @Override
    public int sendEmail(String loginName, String subjet, String message, String attachFile) {

        EiInfo eiInfo = new EiInfo();
        eiInfo.set("loginName", loginName);
        eiInfo.set("subject", subjet);
        eiInfo.set("message", message);
        eiInfo.set("attachFile", attachFile);
        eiInfo.set(EiConstant.serviceId, "S_EM_05");
        EiInfo outInfo = XServiceManager.call(eiInfo);
        return outInfo.getStatus();
    }

    public EiInfo sendEmailMessage(String loginName, String subjet, String message, String attachFile) {

        EiInfo eiInfo = new EiInfo();
        eiInfo.set("loginName", loginName);
        eiInfo.set("subject", subjet);
        eiInfo.set("message", message);
        eiInfo.set("attachFile", attachFile);
        eiInfo.set(EiConstant.serviceId, "S_EM_05");
        EiInfo outInfo = XServiceManager.call(eiInfo);
        return outInfo;
    }
}
